package com.empire.module.sporttery.vo;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 足彩 胜负平表
 *
 * @author qihang
 * @since 2022-10-05
 */
@Data
@Accessors(chain = true)
public class WinBurdenFootballMatchVO implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer id;
    /**
     * 500wan的有戏Id
     */
    private Integer matchId;

    /**
     * 编号
     */
    private String number;

    /**
     * 期号
     */
    private String issueNo;

    /**
     * 颜色
     */
    private String color;

    /**
     * 赛事
     */
    private String match;

    /**
     * 联赛地址
     */
    private String matchUrl;

    /**
     * 分析链接
     */
    private String analysis;

    /**
     * 主队
     */
    private String homeTeam;

    /**
     * 客队
     */
    private String visitingTeam;

    /**
     * 是否单关 0 否 1 是
     */
    private String isSingle;

    /**
     * 截止时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    private LocalDateTime deadline;

    /**
     * 开赛时间
     */
    private String openTime;

    public String getScore() {
        return StrUtil.isEmpty(score)? "VS" : score;
    }

    /**
     * 比分
     */
    private String score;

    /**
     * 主队链接
     */
    private String homeTeamUrl;

    /**
     * 客队链接
     */
    private String visitTeamUrl;
    /**
     * 初胜赔
     */
    private String winPay;
    private Integer winFlag;
    private String winRate;
    /**
     * 初平赔
     */
    private String drawPay;
    private Integer drawWinFlag;
    private String drawWinRate;
    /**
     * 初客赔
     */
    private String visitPay;
    private Integer visitWinFlag;
    private String visitWinRate;
    /**
     * 即时胜赔
     */
    private String letWinPay;
    private String letWinRate;

    public String setLetDrawPay() {
        return letDrawPay;
    }

    public String setLetWinPay() {
        return letWinPay;
    }

    public String setLetVisitPay() {
        return letVisitPay;
    }

    /**
     * 即时平赔
     */
    private String letDrawPay;
    private String letDrawWinRate;

    /**
     * 即时客赔
     */
    private String letVisitPay;
    private String letVisitWinRate;

    /**
     * (即时赔率概率 - 初赔赔率概率) * 1000000
     */
    private String minusWinRate;
    private String minusDrawWinRate;
    private String minusVisitWinRate;

    /**
     * 选它
     */
    private Integer winSelect;
    private Integer drawWinSelect;
    private Integer visitWinSelect;

    public String getMinusVisitWinRate() {
        if (StrUtil.isNotEmpty(visitWinRate) && StrUtil.isNotEmpty(letVisitWinRate)) {
            visitWinRate = visitWinRate.replace("(\uD83C\uDC04\uFE0F)", "");
            letVisitWinRate = letVisitWinRate.replace("(\uD83C\uDC04\uFE0F)", "");
            minusVisitWinRate = String.format("%.0f", Double.parseDouble(letVisitWinRate) * 1000000 - Double.parseDouble(visitWinRate) * 1000000);
        }
        return minusVisitWinRate;
    }

    public String getMinusDrawWinRate() {
        if (StrUtil.isNotEmpty(drawWinRate) && StrUtil.isNotEmpty(letDrawWinRate)) {
            drawWinRate = drawWinRate.replace("(\uD83C\uDC04\uFE0F)", "");
            letDrawWinRate = letDrawWinRate.replace("(\uD83C\uDC04\uFE0F)", "");
            minusDrawWinRate = String.format("%.0f", Double.parseDouble(letDrawWinRate) * 1000000 - Double.parseDouble(drawWinRate) * 1000000);
        }
        return minusDrawWinRate;
    }

    public String getMinusWinRate() {
        if (StrUtil.isNotEmpty(winRate) && StrUtil.isNotEmpty(letWinRate)) {
            winRate = winRate.replace("(\uD83C\uDC04\uFE0F)", "");
            letWinRate = letWinRate.replace("(\uD83C\uDC04\uFE0F)", "");
            minusWinRate = String.format("%.0f", Double.parseDouble(letWinRate) * 1000000 - Double.parseDouble(winRate) * 1000000);
        }
        return minusWinRate;
    }

}
